package com.d3works.apps.sale.service.config;

import com.d3works.apps.base.db.Company;
import com.d3works.apps.base.exceptions.BaseExceptionMessage;
import com.d3works.apps.sale.db.SaleConfig;
import com.d3works.apps.sale.exception.SaleExceptionMessage;
import com.d3works.exception.D3worksException;
import com.d3works.exception.db.repo.TraceBackRepository;
import com.d3works.i18n.I18n;

public class SaleConfigServiceImpl implements SaleConfigService {

  public SaleConfig getSaleConfig(Company company) throws D3worksException {

    SaleConfig saleConfig = company.getSaleConfig();

    if (saleConfig == null) {
      throw new D3worksException(
          company,
          TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
          I18n.get(SaleExceptionMessage.SALE_CONFIG_1),
          I18n.get(BaseExceptionMessage.EXCEPTION),
          company.getName());
    }

    return saleConfig;
  }
}
